package zmee.bid.formplugin;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.db.DB;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;

import java.util.List;

/**
* @author lijiawang
* @Date 2022/12/5 15:37
* @Description:招标立项申请单转换
*/
public class SrcDemandConvertPlugIn extends AbstractConvertPlugIn {

    @Override
    public void afterConvert(AfterConvertEventArgs e) {
        ExtendedDataEntity[] extendedDataEntities = e.getTargetExtDataEntitySet().FindByEntityKey(this.getTgtMainType().toString());
        for (int i = 0; i < extendedDataEntities.length; i++) {
            ExtendedDataEntity ext=extendedDataEntities[i];
            DynamicObject dataEntity = ext.getDataEntity();//目标单据
            if (dataEntity.get("id") instanceof Long && ((Long) dataEntity.get("id")) < 1) {
                long id = DB.genGlobalLongId();
                dataEntity.set("id", id);
            }
            dataEntity.set("checkbox",true);
        }
    }
}
